import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/pages/main/main_page.dart';
import 'package:yysk_app/pages/nft_pages/home_pages/collection_detail/collection_detail_page.dart';
import 'package:yysk_app/pages/nft_pages/pay_pages/result_payment/result_payment_controller.dart';
import 'package:yysk_app/pages/nft_pages/pay_pages/result_payment/result_payment_zhifu_controller.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/widget/button_widget.dart';
import 'package:yysk_app/widget/custom_app_bar.dart';
import 'package:yysk_app/widget/custom_app_bar2.dart';
import 'package:yysk_app/widget/image_asset_widget.dart';
import 'package:yysk_app/widget/lazy_network_image.dart';

class ResultPaymentZhifuPage extends GetView<ResultPaymentZhifuController> {
  static const path = '/ResultPaymentZhifuPage';
  const ResultPaymentZhifuPage({super.key});

  @override
  Widget build(BuildContext context) {
    double top = MediaQuery.of(context).padding.top;
    return PopScope(
      canPop: false,
      child: Scaffold(
      // key: _scaffoldKey,
      resizeToAvoidBottomInset: false,
      // appBar: CustomAppBar(title: '收银台', context: context, actions: []),
      body: Obx(
        () => Stack(
          children: [
            SizedBox(
              width: context.width,
              child: ImageAssetWidget(
                    width: 375.px,
                    height: 582.px,
                    imageUrl: 'static/images/bg.png',
                  ),
            ),
            Padding(
              padding: EdgeInsets.only(left: 0.px, top: top, right: 0.px),
              child: Column(
                children: [
                  CustomAppBar2(
                    title: '',
                    context: context,
                    beforBack: () {
                      controller.callbackmain();
                    },
                  ),

                  Expanded(
                    child: ListView(
                      // mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Padding(
                          padding: EdgeInsets.only(left: 14.px, right: 14.px),
                          child: Column(
                            children: [
                              Center(
                                child: Stack(
                                  children: [
                                    Container(
                                      padding: EdgeInsets.only(top: 62.px),
                                      child: Center(
                                        child: ImageAssetWidget(
                                          width: 80.px,
                                          height: 80.px,
                                          imageUrl:
                                              controller.detail.value?.status ==
                                                      'PROCESSING'
                                                  ? 'static/images/logo.png'
                                                  : (controller
                                                              .detail
                                                              .value
                                                              ?.status ==
                                                          'SUCCESS'
                                                      ? 'static/images/logo.png'
                                                      : 'static/images/logo.png'),
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                              SizedBox(height: 26.px),
                              Row(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: [
                                  Text(
                                    controller.detail.value?.status ==
                                            'PROCESSING'
                                        ? '支付中'
                                        : (controller.detail.value?.status ==
                                                'SUCCESS'
                                            ? '已支付'
                                            : '已关闭'),
                                    style: TextStyle(
                                      fontSize: 24.px,
                                      color: AppColors.startColor,
                                      fontWeight: FontWeight.w500,
                                      fontFamily: 'CustomPINGFANG',
                                    ),
                                  ),
                                ],
                              ),
                              SizedBox(height: 42.px),
                              Container(
                                width: context.width,

                                decoration: BoxDecoration(
                                  color: AppColors.backgroundColorGrey2,
                                  borderRadius: BorderRadius.circular(8.px),
                                ),

                                child:
                                Column(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    _infoItem(
                                      context: context,
                                      title: '支付金额',
                                      value:
                                          '￥${controller.detail.value?.tradeAmt}',
                                      fontSize: 18.px,
                                    ),
                                    controller.detail.value?.payMethod ==
                                            'HUIFU'
                                        ? _infoItem(
                                          context: context,
                                          title: '支付方式',
                                          value:
                                              '${controller.detail.value?.payMethodName}-${controller.detail.value?.bankName}（${controller.detail.value?.bankCardNo} ）',
                                          fontSize: 12.px,
                                        )
                                        : _infoItem(
                                          context: context,
                                          title: '支付方式',
                                          value:
                                              controller
                                                  .detail
                                                  .value
                                                  ?.payMethodName ??
                                              '',
                                          fontSize: 12.px,
                                        ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    width: 375.px,
                    color: AppColors.backgroundColorBlack,
                    margin: EdgeInsets.only(bottom: 20.px),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        SizedBox(height: 12.px),
                        ButtonWidget(
                          height: 44.px,
                          width: 322.px,
                          fontSize: 14.px,
                          label: '返回',
                          contentType: ContentType.text,
                          onPressed: () {
                            controller.callbackmain();
                          },
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ));
    
  }

  _infoItem({
    required BuildContext context,
    required String title,
    required String value,
    double fontSize = 12,
  }) {
    return Container(
      width: context.width,
      padding: EdgeInsets.fromLTRB(11.px, 0.px, 10.px, 0.px),
      height: 40.px,
      decoration: BoxDecoration(
        color: AppColors.backgroundColorGrey2,
        borderRadius: BorderRadius.circular(8.px),
      ),

      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Expanded(
            child: Text(
              title,
              style: TextStyle(
                fontSize: 14.px,
                color: AppColors.backgroundColorGrey,
                overflow: TextOverflow.ellipsis,
              ),
            ),
          ),
          Text(
            value,
            style: TextStyle(
              fontSize: fontSize,
              color: AppColors.backgroundColorGrey,
              overflow: TextOverflow.ellipsis,
            ),
          ),
        ],
      ),
    );
  }
}
